home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 56194 / 56194.xpi / install.js < prev    next >
Text File  |  2010-01-13  |  2KB  |  66 lines

  1. var linkextendXpiInstaller = {
  2.     extFullName: "TopSite",
  3.     extShortName: "topsite",
  4.     extVersion: "1.0.4",
  5.     extAuthor: "SimilarGroup",
  6.     extLocaleNames: ['en-US'],
  7.     extPostInstallMessage: null,
  8.     
  9.     profileInstall: true,
  10.     silentInstall: false,
  11.  
  12.     install: function() {
  13.         if (Install.arguments && (Install.arguments == "p=0" || Install.arguments == "p=1")) {
  14.             this.profileInstall = (Install.arguments == "p=1");
  15.             this.silentInstall = true;
  16.         }        
  17.  
  18.         var jarName = this.extShortName + ".jar";
  19.         var profileDir = Install.getFolder("Profile", "chrome");
  20.  
  21.         if (File.exists(Install.getFolder(profileDir, jarName))) {
  22.             if (!this.silentInstall)
  23.                 Install.alert("Updating existing Profile install of " + this.extFullName + " to version " + this.extVersion + ".");
  24.             this.profileInstall = true;
  25.         } else if (!this.silentInstall)    {
  26.             this.profileInstall = Install.confirm("Install " + this.extFullName + " " + this.extVersion + " to your Profile directory (OK) or your Browser directory (Cancel)?");
  27.         }
  28.         
  29.         Install.initInstall(this.extFullName, this.extShortName, this.extVersion);
  30.         
  31.         var installPath = (this.profileInstall)?profileDir:Install.getFolder("chrome");
  32.         
  33.         Install.addFile(null, "chrome/" + jarName, installPath, null);
  34.         
  35.         var jarPath = Install.getFolder(installPath, jarName);
  36.         var installType = (this.profileInstall)?Install.PROFILE_CHROME:Install.DELAYED_CHROME;
  37.         
  38.         Install.registerChrome(Install.CONTENT | installType, jarPath, "content/");
  39.         
  40.         for (var locale in this.extLocaleNames) {
  41.             var regPath = "locale/" + this.extLocaleNames[locale] + "/" + this.extShortName + "/";
  42.             Install.registerChrome(Install.LOCALE | installType, jarPath, regPath);
  43.         }
  44.         Install.registerChrome(Install.SKIN | installType, jarPath, "skin/");
  45.         
  46.         if (!this.profileInstall) {
  47.             installPath = Install.getFolder("Components");
  48.             for (var comp in this.extComponents) {
  49.                 Install.addFile(null, "components/" + this.extComponents[comp], installPath, null);
  50.             }
  51.         }
  52.  
  53.         var err = Install.performInstall();
  54.         if (err == Install.SUCCESS || err == Install.REBOOT_NEEDED) {
  55.             if (!this.silentInstall && this.extPostInstallMessage)
  56.                 Install.alert(this.extPostInstallMessage);
  57.         } else {
  58.             if (!this.silentInstall) 
  59.                 Install.alert("Error: Could not install " + this.extFullName + " " + this.extVersion + " (Error code: " + err + ")");
  60.             Install.cancelInstall(err);
  61.         }
  62.     }
  63. };
  64.  
  65. linkextendXpiInstaller.install();
  66.